package com.gao.feign;

import com.gao.pojo.Dept;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @ClassName FeignDeptFallback
 * @Author Mr.Gao
 * @Date 2020/2/9 19:26
 * @Description:
 */


@Component
public class FeignDeptFallback implements FallbackFactory {
    public FeignDept create(Throwable throwable) {
        return new FeignDept() {
            public Dept getDeptById(Integer id) {
                return new Dept().setDeptno(id).setDname("服务降级中，暂时不可用").setDb_source("no this database");
            }

            public List<Dept> getDeptAll() {
                return null;
            }

            public boolean addDept(Dept dept) {
                return false;
            }
        };
    }
}
